#  Name:        hooks
#  Version:     0.1
#  Depends:		linuxrules, [m|g]awk

#  Purpose:		AWK library providing action hooks
#               to linuxrules.
#  Goal:        Keep a sane set of rules,
#               with on-the-fly setup.
#  Creation:   	Mon Oct 25 2010
#  Modified:	Mon Oct 25 2010, 09:40:51
#  Insects:		What species? No bugs known,yet.
#
#  Feel free to contact me at:
#  <http://sites.google.com/site/code933k>
#  in case of bugs, updates, proposals or comments

#  Copyright (C) 2010 Mario García H.
#
#  THIS PROGRAM IS FREE SOFTWARE:
#  Distributed in the hope that it will be useful, but
#  WITHOUT ANY WARRANTY; without even the implied warranty
#  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
#  You should have received a copy of the GNU GPL License
#  version 3 or superior along with this program.
#  If not, see: <http://www.gnu.org/licenses/gpl.txt>

# DO NOT USE, THIS IS JUST A DRAFT !!

function Battery (alarm, alarm_command, lower, lower_command) {
# Battery: Triggers a shell command on given alarm, lower charge
    if ( alarm != lower != 0 )
        while (("BATTCH" SUBSEP idx) in _acpi)
        {
            if (_acpi["BATTCH" SUBSEP idx] == alarm)
            {
                system(alarm_command)
            }

            if (_acpi["BATTCH" SUBSEP idx] == lower)
            {
                system(lower_command)
            }
        }
}

function Adapter (plugd_command, unpld_command) {
# Adapter: Triggers a shell command for each plug / unplug state
        if (_acpi["ACAD"] == "on-line")
        {
            system(plugd_command)
        }

        if (_acpi["ACAD"] == "off-line")
        {
            system(unpld_command)
        }
}

function Adapter (plugd_command, unpld_command) {
# Adapter: Triggers a shell command for each plug / unplug state
        if (_acpi["ACAD"] == "on-line")
        {
            system(plugd_command)
        }

        if (_acpi["ACAD"] == "off-line")
        {
            system(unpld_command)
        }
}

# vim:ft=awk:
